<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="org.waddy.servlet.User"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	User user = (User) session.getAttribute("user");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>DWR</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<script type="text/javascript" src="<%=basePath%>/dwr/engine.js"></script>
		<script type="text/javascript" src="<%=basePath%>/dwr/util.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/dwr/interface/ChatServer.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/js/jquery-1.3.1.min.js"></script>

		<script type="text/javascript" src="<%=basePath%>/js/chat.js"></script>

		<script type="text/javascript">
		//表示在刷新页面或关闭页面时调用服务端清除多余ScriptSession的方法.
		//一定要加上window.onbeforeunload事件,这样才能在IE中有效.
		   window.onbeforeunload=ChatServer.exitGame();
		   document.body.onunload=ChatServer.exitGame();
  		</script>
<script>  
        function getData(){  
            dwrPush.sendMessage(null);  
        }  
          
       function receiveMessages(message) {  
            //alert("message="+message);
            var msg = eval("("+message+")");  
            //alert("msg="+msg);
            //var temp  = msg.split(",");  
            //var num = temp[0];  
            //var status = temp[1];  
            //var accessTime = new Date(temp[2]).format('yyyy-MM-dd hh:mm:ss');  
            //var accessName = temp[3];  
            //var totalTime = temp[4];  
            var num = 0;  
            var status = message;  
            var accessTime = 0;  
            var accessName = 0;  
            var totalTime = 0;  
            var newRow = document.getElementById('tableData').insertRow(2);  
            var cell0 = newRow.insertCell(0);  
            var cell1 = newRow.insertCell(1);  
            var cell2 = newRow.insertCell(2);  
            var cell3 = newRow.insertCell(3);  
            var cell4 = newRow.insertCell(4);  
            cell0.innerHTML = num;  
            cell1.innerHTML = status;  
            if(status =="连接失败"){  
                cell1.style.color = 'red';  
            }  
            cell2.innerHTML = accessTime;  
            cell3.innerHTML = accessName;  
            cell4.innerHTML = totalTime;  
    }     
           //Date.prototype.format = function(format){.......}  
    </script>  
</head>

<!-- 此处是关键 -->
<body onload="dwr.engine.setActiveReverseAjax(true);ChatServer.send('0',' ','');">  
    <div align="center">
    	<!-- 任务监控表：任务队列数量、最近提取数据数量和时间 -->  
        <TABLE title="任务监控表" class="list" align="center" id="tableData">  
        <tr id="titleData"><td colspan="4">集群节点监控表</td><td colspan="1" onclick="getData()" style="size: 10px"><a href="<c:url value='/monitorResult/monitor.htm?action=getMonitorRecord'/>">更多</a></td></tr>  
        <TR id="headData" bgcolor="#fffce7" style="color:#968054;border: 1px">
            <TD>节点号</TD>
            <TD>节点地址</TD>
            <TD>连接状态</TD>
            <TD title="登记注册时间">启动时间</TD>
            <TD>累计交互次数</TD>
            <TD>最近访问时间</TD>
            <TD>最近响应时间</TD>
         </TR>  
        </TABLE>
    	<!-- 节点监控表：节点连接情况（存活）、最近交互时间 -->  
    	<!-- 任务节点运行监控表（请求时更新）：处理数量、累计数量等 -->  
    </DIV>      
 </body>  
 
</html> 